<template>
  <div id="PGSGAList">
    <van-nav-bar title="营养评测" left-arrow left-text="返回" @click-left="onClickLeft" fixed 
      placeholder></van-nav-bar>
    <div class="main">
      <div class="box">
        <div class="top date">
          <div class="topLeft"></div>
        </div>
        <div class="content">
            <div class="rom" v-for="(item,idx) in list" :key="idx" @click="toPGSGA(item)">
              <div class="boxLeft" span="20">
                 <div class="journalTitle">
                  {{item.created !== undefined ? item.created.split(" ")[0] : '' }}
                </div>
                <div class="weightCon">
                    <p>得分： {{ item.hdfen + item.jsfen + item.tzfen + item.zzfen }}</p>
                    <p style="margin-left:20px">{{ item.hdfen + item.jsfen + item.tzfen + item.zzfen> 2 ? "营养不良" : "营养良好" }}</p>
                </div>
              </div>
              <div class="boxRight" >
                  <van-icon name="arrow" />
              </div>
            </div>
        </div>  
      </div>
    </div>
    <!-- <van-empty image="error" description="暂无数据" v-if="list.length === 0" /> -->
  </div>
</template>

<script>
import { pgsgaList } from "@/apis/patient"
export default {
  data() {
    return {
      detailId: null,
      list: [],
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1); //返回上一层
    },
    toPGSGA(item) {
      localStorage.setItem('pgsga',JSON.stringify(item))
      this.$router.push(`/pg-SGA/`)
    },
    records() {
      var token = sessionStorage.getItem(token)
      if( token!=""){
        pgsgaList({hzid: this.$route.params.id})
        .then((res) => {
          this.list = res.data.list
        })
        .catch((err) => {
          if(err.msg){
            this.$toast(err.msg);
          }else{
            this.$toast("网络错误"); 
          }
        });
      }
      
    },
  },
  mounted() {
    this.records();
  },
  created() {
    this.detailId = this.$route.params.pid;
  },
};
</script>

<style lang="less">
html {
  min-height: 100vh;
  background-color: #fff;
}
#PGSGAList {
  .van-icon,.van-nav-bar__text {
    color: #404040;
  }
  .main {
    padding: 0 20px;
    min-height: 100%;
    background-color: #fff;
    .box {
      padding: 15px 0;
      
      .top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .topLeft {
          font-family: SourceHanSansCN;
          font-size: 15px;
          color: #151515;
        }
        .topRight {
          font-family: SourceHanSansCN;
          font-size: 15px;
          color: #4e8af4;
        }
      }
      .content {
          text-align: left;
          padding-bottom: 10px;
         .rom{
            padding: 15px 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #d2d2d2;
            .journalTitle{
              h1{
                  font-weight: bold;
              }
          }
          .weightCon{
            margin-top: 10px;
            display: flex;
            align-items: flex-start;
          }
         }
          
       
      }
    }
  }
}
</style>
